package c.e.a.b.e.c;

import android.app.Activity;
import android.app.Application.ActivityLifecycleCallbacks;
import android.content.Context;
import android.os.Bundle;
import android.os.RemoteException;
import android.os.SystemClock;
import android.util.Log;
import android.util.Pair;
import c.e.a.b.f.b.z5;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.ExecutorService;

/* compiled from: com.google.android.gms:play-services-measurement-sdk-api@@18.0.0 */
public class g {
    public static volatile g i;
    public static Boolean j;
    public final String a;
    public final c.e.a.b.b.j.b b;
    public final ExecutorService c;
    public final c.e.a.b.f.a.a d;
    public final List<Pair<z5, c>> e;
    public int f;
    public boolean g;
    public volatile gc h;

    /* compiled from: com.google.android.gms:play-services-measurement-sdk-api@@18.0.0 */
    public abstract class a implements Runnable {
        public final long a = System.currentTimeMillis();
        public final long b;
        public final boolean c;

        public a(boolean z) {
            Objects.requireNonNull((c.e.a.b.b.j.c) g.this.b);
            Objects.requireNonNull((c.e.a.b.b.j.c) g.this.b);
            this.b = SystemClock.elapsedRealtime();
            this.c = z;
        }

        public abstract void a() throws RemoteException;

        public void b() {
        }

        public void run() {
            if (g.this.g) {
                b();
                return;
            }
            try {
                a();
            } catch (Exception e) {
                g.this.b(e, false, this.c);
                b();
            }
        }
    }

    /* compiled from: com.google.android.gms:play-services-measurement-sdk-api@@18.0.0 */
    public class b implements ActivityLifecycleCallbacks {
        public final void onActivityCreated(Activity activity, Bundle bundle) {
            g gVar = g.this;
            gVar.c.execute(new e0(this, bundle, activity));
        }

        public final void onActivityDestroyed(Activity activity) {
            g gVar = g.this;
            gVar.c.execute(new j0(this, activity));
        }

        public final void onActivityPaused(Activity activity) {
            g gVar = g.this;
            gVar.c.execute(new f0(this, activity));
        }

        public final void onActivityResumed(Activity activity) {
            g gVar = g.this;
            gVar.c.execute(new g0(this, activity));
        }

        public final void onActivitySaveInstanceState(Activity activity, Bundle bundle) {
            ec ecVar = new ec();
            g gVar = g.this;
            gVar.c.execute(new h0(this, activity, ecVar));
            Bundle L0 = ecVar.L0(50);
            if (L0 != null) {
                bundle.putAll(L0);
            }
        }

        public final void onActivityStarted(Activity activity) {
            g gVar = g.this;
            gVar.c.execute(new d0(this, activity));
        }

        public final void onActivityStopped(Activity activity) {
            g gVar = g.this;
            gVar.c.execute(new i0(this, activity));
        }
    }

    /* compiled from: com.google.android.gms:play-services-measurement-sdk-api@@18.0.0 */
    public static class c extends b {
        public final z5 a;

        public c(z5 z5Var) {
            this.a = z5Var;
        }

        public final void c0(String str, String str2, Bundle bundle, long j) {
            this.a.a(str, str2, bundle, j);
        }

        public final int q() {
            return System.identityHashCode(this.a);
        }
    }

    /* JADX WARNING: Removed duplicated region for block: B:25:0x006d  */
    /* JADX WARNING: Removed duplicated region for block: B:23:0x0063  */
    /* JADX WARNING: Removed duplicated region for block: B:14:0x0053 A:{SYNTHETIC, Splitter:B:14:0x0053} */
    /* JADX WARNING: Removed duplicated region for block: B:23:0x0063  */
    /* JADX WARNING: Removed duplicated region for block: B:25:0x006d  */
    public g(android.content.Context r9, java.lang.String r10, java.lang.String r11, java.lang.String r12, android.os.Bundle r13) {
        /*
        r8 = this;
        r8.<init>();
        if (r10 == 0) goto L_0x000f;
    L_0x0005:
        r0 = e(r11, r12);
        if (r0 != 0) goto L_0x000c;
    L_0x000b:
        goto L_0x000f;
    L_0x000c:
        r8.a = r10;
        goto L_0x0013;
    L_0x000f:
        r10 = "FA";
        r8.a = r10;
    L_0x0013:
        r10 = c.e.a.b.b.j.c.a;
        r8.b = r10;
        r7 = new c.e.a.b.e.c.o;
        r7.m1329init();
        r10 = new java.util.concurrent.ThreadPoolExecutor;
        r5 = java.util.concurrent.TimeUnit.SECONDS;
        r6 = new java.util.concurrent.LinkedBlockingQueue;
        r6.<init>();
        r1 = 1;
        r2 = 1;
        r3 = 60;
        r0 = r10;
        r0.<init>(r1, r2, r3, r5, r6, r7);
        r0 = 1;
        r10.allowCoreThreadTimeOut(r0);
        r10 = java.util.concurrent.Executors.unconfigurableExecutorService(r10);
        r8.c = r10;
        r10 = new c.e.a.b.f.a.a;
        r10.m1375init(r8);
        r8.d = r10;
        r10 = new java.util.ArrayList;
        r10.<init>();
        r8.e = r10;
        r10 = 0;
        r1 = "google_app_id";
        r1 = c.e.a.b.b.j.d.u(r9, r1);	 Catch:{ IllegalStateException -> 0x0050 }
        if (r1 == 0) goto L_0x0050;
    L_0x004e:
        r1 = 1;
        goto L_0x0051;
    L_0x0050:
        r1 = 0;
    L_0x0051:
        if (r1 == 0) goto L_0x0060;
    L_0x0053:
        r1 = "com.google.firebase.analytics.FirebaseAnalytics";
        java.lang.Class.forName(r1);	 Catch:{ ClassNotFoundException -> 0x005a }
        r1 = 1;
        goto L_0x005b;
    L_0x005a:
        r1 = 0;
    L_0x005b:
        if (r1 == 0) goto L_0x005e;
    L_0x005d:
        goto L_0x0060;
    L_0x005e:
        r1 = 0;
        goto L_0x0061;
    L_0x0060:
        r1 = 1;
    L_0x0061:
        if (r1 != 0) goto L_0x006d;
    L_0x0063:
        r8.g = r0;
        r9 = r8.a;
        r10 = "Disabling data collection. Found google_app_id in strings.xml but Google Analytics for Firebase is missing. Remove this value or add Google Analytics for Firebase to resume data collection.";
        android.util.Log.w(r9, r10);
        return;
    L_0x006d:
        r1 = e(r11, r12);
        if (r1 != 0) goto L_0x0093;
    L_0x0073:
        if (r11 == 0) goto L_0x007f;
    L_0x0075:
        if (r12 == 0) goto L_0x007f;
    L_0x0077:
        r10 = r8.a;
        r0 = "Deferring to Google Analytics for Firebase for event data collection. https://goo.gl/J1sWQy";
        android.util.Log.v(r10, r0);
        goto L_0x0093;
    L_0x007f:
        if (r11 != 0) goto L_0x0083;
    L_0x0081:
        r1 = 1;
        goto L_0x0084;
    L_0x0083:
        r1 = 0;
    L_0x0084:
        if (r12 != 0) goto L_0x0087;
    L_0x0086:
        goto L_0x0088;
    L_0x0087:
        r0 = 0;
    L_0x0088:
        r10 = r1 ^ r0;
        if (r10 == 0) goto L_0x0093;
    L_0x008c:
        r10 = r8.a;
        r0 = "Specified origin or custom app id is null. Both parameters will be ignored.";
        android.util.Log.w(r10, r0);
    L_0x0093:
        r10 = new c.e.a.b.e.c.j;
        r1 = r10;
        r2 = r8;
        r3 = r11;
        r4 = r12;
        r5 = r9;
        r6 = r13;
        r1.m5609init(r2, r3, r4, r5, r6);
        r11 = r8.c;
        r11.execute(r10);
        r9 = r9.getApplicationContext();
        r9 = (android.app.Application) r9;
        if (r9 != 0) goto L_0x00b3;
    L_0x00ab:
        r9 = r8.a;
        r10 = "Unable to register lifecycle notifications. Application null.";
        android.util.Log.w(r9, r10);
        return;
    L_0x00b3:
        r10 = new c.e.a.b.e.c.g$b;
        r10.m1288init();
        r9.registerActivityLifecycleCallbacks(r10);
        return;
        */
        throw new UnsupportedOperationException("Method not decompiled: c.e.a.b.e.c.g.m1292init(android.content.Context, java.lang.String, java.lang.String, java.lang.String, android.os.Bundle):void");
    }

    public static g a(Context context, String str, String str2, String str3, Bundle bundle) {
        Objects.requireNonNull(context, "null reference");
        if (i == null) {
            synchronized (g.class) {
                if (i == null) {
                    i = new g(context, null, null, null, bundle);
                }
            }
        }
        return i;
    }

    /* JADX WARNING: Removed duplicated region for block: B:24:0x0032 A:{SYNTHETIC, Splitter:B:24:0x0032} */
    /* JADX WARNING: Removed duplicated region for block: B:20:0x002e A:{SYNTHETIC, Splitter:B:20:0x002e} */
    /* JADX WARNING: No exception handlers in catch block: Catch:{  } */
    public static void d(android.content.Context r7) {
        /*
        r0 = java.lang.Boolean.TRUE;
        r1 = c.e.a.b.e.c.g.class;
        monitor-enter(r1);
        r2 = j;	 Catch:{ Exception -> 0x0054 }
        if (r2 == 0) goto L_0x000b;
    L_0x0009:
        monitor-exit(r1);	 Catch:{ all -> 0x0052 }
        goto L_0x005f;
    L_0x000b:
        r2 = "app_measurement_internal_disable_startup_flags";
        b.i.b.f.N(r2);	 Catch:{ Exception -> 0x0054 }
        r3 = 0;
        r4 = c.e.a.b.b.k.b.a(r7);	 Catch:{ NameNotFoundException -> 0x002b }
        r5 = r7.getPackageName();	 Catch:{ NameNotFoundException -> 0x002b }
        r6 = 128; // 0x80 float:1.794E-43 double:6.32E-322;
        r4 = r4.a(r5, r6);	 Catch:{ NameNotFoundException -> 0x002b }
        if (r4 == 0) goto L_0x002b;
    L_0x0021:
        r4 = r4.metaData;	 Catch:{ NameNotFoundException -> 0x002b }
        if (r4 != 0) goto L_0x0026;
    L_0x0025:
        goto L_0x002b;
    L_0x0026:
        r2 = r4.getBoolean(r2);	 Catch:{ NameNotFoundException -> 0x002b }
        goto L_0x002c;
    L_0x002b:
        r2 = 0;
    L_0x002c:
        if (r2 == 0) goto L_0x0032;
    L_0x002e:
        j = r0;	 Catch:{ Exception -> 0x0054 }
        monitor-exit(r1);	 Catch:{ all -> 0x0052 }
        goto L_0x005f;
    L_0x0032:
        r2 = "com.google.android.gms.measurement.prefs";
        r7 = r7.getSharedPreferences(r2, r3);	 Catch:{ Exception -> 0x0054 }
        r2 = "allow_remote_dynamite";
        r3 = 1;
        r2 = r7.getBoolean(r2, r3);	 Catch:{ Exception -> 0x0054 }
        r2 = java.lang.Boolean.valueOf(r2);	 Catch:{ Exception -> 0x0054 }
        j = r2;	 Catch:{ Exception -> 0x0054 }
        r7 = r7.edit();	 Catch:{ Exception -> 0x0054 }
        r2 = "allow_remote_dynamite";
        r7.remove(r2);	 Catch:{ Exception -> 0x0054 }
        r7.apply();	 Catch:{ Exception -> 0x0054 }
        goto L_0x005e;
    L_0x0052:
        r7 = move-exception;
        goto L_0x0060;
    L_0x0054:
        r7 = move-exception;
        r2 = "FA";
        r3 = "Exception reading flag from SharedPreferences.";
        android.util.Log.e(r2, r3, r7);	 Catch:{ all -> 0x0052 }
        j = r0;	 Catch:{ all -> 0x0052 }
    L_0x005e:
        monitor-exit(r1);	 Catch:{ all -> 0x0052 }
    L_0x005f:
        return;
    L_0x0060:
        monitor-exit(r1);	 Catch:{ all -> 0x0052 }
        throw r7;
        */
        throw new UnsupportedOperationException("Method not decompiled: c.e.a.b.e.c.g.d(android.content.Context):void");
    }

    public static boolean e(String str, String str2) {
        if (!(str2 == null || str == null)) {
            Object obj;
            try {
                Class.forName("com.google.firebase.analytics.FirebaseAnalytics");
                obj = 1;
            } catch (ClassNotFoundException unused) {
                obj = null;
            }
            if (obj == null) {
                return true;
            }
        }
        return false;
    }

    public final void b(Exception exception, boolean z, boolean z2) {
        this.g |= z;
        if (z) {
            Log.w(this.a, "Data collection startup failed. No data will be collected.", exception);
            return;
        }
        String str = "Error with data collection. Data lost.";
        if (z2) {
            this.c.execute(new y(this, str, exception));
        }
        Log.w(this.a, str, exception);
    }

    public final void c(String str, String str2, Bundle bundle, boolean z, boolean z2, Long l) {
        this.c.execute(new c0(this, null, str, str2, bundle, z, z2));
    }
}
